39513f
@@ -80,10 +80,15 @@
public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, Seria
      *
      * @throws IllegalArgumentException if the object to be added does not implement
      * {@link Comparable} and the {@link TreeBag} is using natural ordering
+     * @throws NullPointerException if the specified key is null and this bag uses
+     * natural ordering, or its comparator does not permit null keys
      */
     @Override
     public boolean add(final E object) {
         if(comparator() == null && !(object instanceof Comparable)) {
+            if (object == null) {
+                throw new NullPointerException();
+            }
             throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
                                                "a naturally ordered TreeBag as it does not implement Comparable");
         }
